Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Channel constructors, change kwargs to positional args. #32818

Merged
merged 6 commits into from
Aug 11, 2019

Conversation

NHDaly
Copy link
Member

@NHDaly NHDaly commented Aug 7, 2019

Oops, fixes this error, introduced in #30855:

WARNING: Method definition (::Type{Base.Channel{T}})(Function) where {T} in module Base at channels.jl:133 overwritten at channels.jl:136.

Oops, fixes this error, introduced in e891bca:
WARNING: Method definition (::Type{Base.Channel{T}})(Function) where {T} in module Base at channels.jl:133 overwritten at channels.jl:136.
base/channels.jl Outdated Show resolved Hide resolved
base/channels.jl Outdated Show resolved Hide resolved
NHDaly added 3 commits August 9, 2019 16:45
"Soft" deprecation of the old `Channel(f::Function; csize=0, ctype=Any)`
style in favor of the new `Channel{T=Any}(f::Function, size=0)`
interface.

Removed the old interface from the docs, so that it is not discoverable,
and included a `!!! compat` note that the new interface is new in Julia
1.3, and the old interface should not be used.
@NHDaly NHDaly force-pushed the Channel-constructors branch from d042f3b to b04fb84 Compare August 9, 2019 21:06
@NHDaly
Copy link
Member Author

NHDaly commented Aug 9, 2019

Okay, this should be good to go! :) Thanks again for the review.
PTAL

I think I will open one more PR for adding the spawn=false kwarg to the channels so that it can get a more thorough, independent review. Does that sound good? Thanks!

@JeffBezanson
Copy link
Member

Looks good. I think this is missing a Channel(::Function, size) constructor (i.e. with no {T})?

@NHDaly
Copy link
Member Author

NHDaly commented Aug 9, 2019

Aye, so it is. :) Thanks good catch!

(I was about to fix it by pushing Channel(func::Function, args...; kwargs...) = Channel{Any}(func, args...; kwargs...), but then i realized i could just have a single T=Any constructor defined as Channel(args...; kwargs...) = Channel{Any}( args...; kwargs...) to cover both the function and non-function cases. Do you think that's valuable? Or is it less clear? Thanks!)

@JeffBezanson
Copy link
Member

Either seems fine to me.

@NHDaly
Copy link
Member Author

NHDaly commented Aug 9, 2019

EDIT: Ah, actually, i think there's an ambiguity with the ctype= constructors, so i may have to list the args explicitly anyway. :'( Oh maybe not actually.. okay i'll just pick one. thanks

@NHDaly
Copy link
Member Author

NHDaly commented Aug 9, 2019

Looks good. I think this is missing a Channel(::Function, size) constructor (i.e. with no {T})?

Okay thanks! :) Done!

@NHDaly NHDaly changed the title Fix method overwrite warning for Channel constructors Simply Channel constructors, change kwargs to positional args. Aug 9, 2019
@NHDaly NHDaly changed the title Simply Channel constructors, change kwargs to positional args. Simplify Channel constructors, change kwargs to positional args. Aug 9, 2019
@@ -8,9 +8,9 @@ Representation of a channel passing objects of type `T`.
abstract type AbstractChannel{T} end

"""
Channel{T}(sz::Int=0)
Channel{T=Any}(size::Int=0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow... maybe we should actually implement this syntax for defining constructors with default type parameter values? Seems quite possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow... maybe we should actually implement this syntax for defining constructors with default type parameter values? Seems quite possible.

:D Yeah that makes sense to me! It seems pretty readable, and has an intuitive meaning, i think.

@JeffBezanson JeffBezanson merged commit 0852465 into JuliaLang:master Aug 11, 2019
@NHDaly NHDaly deleted the Channel-constructors branch August 12, 2019 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants